package com.ly.web.controller.activiti;

import com.ly.common.core.domain.AjaxResult;
import com.ly.heart.activiti.pojo.ProcessModel;
import com.ly.heart.domain.dto.ActModelQueryDto;
import com.ly.heart.domain.dto.SuspendOrActiveDto;
import com.ly.heart.service.IActModelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;

@Api(value = "actModel", tags = "流程模型管理")
@RestController
@RequestMapping("/actModel")
public class ActModelController {

    @Resource
    private IActModelService actModelService;


    @PostMapping("/deploy")
    @ApiOperation("部署流程")
    public AjaxResult deployActByNode(@RequestBody ProcessModel processModel) throws IOException {
        return actModelService.deployActByNode(processModel);
    }

    @PostMapping("/page")
    @ApiOperation("查询流程模型列表，带分页")
    public AjaxResult getActModelPageList(@RequestBody ActModelQueryDto queryDto){
        return actModelService.getActModelPageList(queryDto);
    }

    @PostMapping("/list")
    @ApiOperation("查询流程模型列表，不带分页")
    public AjaxResult getActModelList(@RequestBody ActModelQueryDto queryDto){
        return actModelService.getActModelList(queryDto);
    }

    @PostMapping("/suspendOrActive")
    @ApiOperation("挂起/激活流程")
    public AjaxResult suspendOrActiveApply(@RequestBody SuspendOrActiveDto activeDto){
        return actModelService.suspendOrActiveApply(activeDto);
    }

    @PostMapping("/remove/{id}")
    @ApiOperation("删除流程")
    public AjaxResult delActModelByDeployId(@PathVariable String id){
        return actModelService.delActModelByDeployId(id);
    }


    @GetMapping("/menu/{menuId}")
    @ApiOperation("根据菜单ID获取关联流程")
    public AjaxResult getActModelByMenuId(@PathVariable String menuId){
        return actModelService.getActModelByMenuId(menuId);
    }

    @GetMapping("/menu/option")
    @ApiOperation("获取菜单下拉选择")
    public AjaxResult getMenuOption(){
        return actModelService.getMenuOption();
    }


}
